//
//  AboutUsViewController.m
//  XingMei
//
//  Created by 姚琪 on 2019/3/25.
//  Copyright © 2019年 钱金军. All rights reserved.
//

#import "AboutUsViewController.h"
#import <SDWebImage/SDImageCache.h>
@interface AboutUsViewController ()
@property(nonatomic , strong) UIScrollView * scroller;

@property(nonatomic , strong) UILabel * contentlb;

@property(nonatomic , strong) UIButton * clearBtn;

@property(nonatomic , strong) UIButton * checkUpdate;

@end


@implementation AboutUsViewController
@synthesize contentlb,clearBtn,checkUpdate;
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavTitleText:@"关于我们"];
    [self layoutScrollerView];
}
-(void)layoutScrollerView{
    _scroller = [[UIScrollView alloc]initWithFrame:CGRectMake(0, Height_NavBar, KScreenWidth, KScreenHeight - Height_NavBar - Height_Indicator)];
    _scroller.showsVerticalScrollIndicator = NO;
    _scroller.showsHorizontalScrollIndicator = NO;
//    _scroller.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(getSystemAnnouncement)];
//    [_scroller.mj_header beginRefreshing];
    [self.view addSubview: _scroller];
    [self layoutContentView];
}
-(void)layoutContentView{
    UILabel *titlelb = [[UILabel alloc]initWithFrame:CGRectMake(0, 50, KScreenWidth, 50)];
    titlelb.font = MediumFont(54);
    titlelb.textColor = rgb(255,116,2);
    titlelb.textAlignment = NSTextAlignmentCenter;
    titlelb.text = @"型美";
    [_scroller addSubview:titlelb];
    //contentlb  内容
    /**
    NSMutableAttributedString *htmlString =[[NSMutableAttributedString alloc] initWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute:[NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:NULL error:nil];
    
    [htmlString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} range:NSMakeRange(0, htmlString.length)];
    
    CGSize textSize = [htmlString boundingRectWithSize:(CGSize){ScreenWidth - 20, CGFLOAT_MAX} options:NSStringDrawingUsesLineFragmentOrigin context:nil].size;
    **/
    contentlb = [[UILabel alloc]initWithFrame:CGRectMake(30,titlelb.bottom +  45, KScreenWidth - 60, 60)];
    contentlb.text = @"协议书有广义和狭义之分。广义的协议书是指社会集团或个人处理各种社会关系、事务时常用的“契约”类文书，包括合同、议定书、条约、公约、联合宣言、联合声明、条据等。狭义的协议书指国家、政党、企业、团体或个人就某个问题经过谈判或共同协商，取得一致意见后，订立的一种具有经济或其它关系的契约性文书。协议书是应用写作的重要组成部分。协议书是社会生活中，协作的双方或数方，为保障各自的合法权益，经双方或数方共同协商达成一致意见后，签订的书面材料。协议书是契约文书的一种。是当事人双方（或多方）为了解决或预防纠纷，或确立某种法律关系，实现一定的共同利益、愿望，经过协商而达成一致后，签署的具有法律效力的记录性应用文。协议书有广义和狭义之分。广义的协议书是指社会集团或个人处理各种社会关系、事务时常用的“契约”类文书，包括合同、议定书、条约、公约、联合宣言、联合声明、条据等。狭义的协议书指国家、政党、企业、团体或个人就某个问题经过谈判或共同协商，取得一致意见后，订立的一种具有经济或其它关系的契约性文书。协议书是应用写作的重要组成部分协议书是社会生活中，协作的双方或数方，为保障各自的合法权益，经双方或数方共同协商达成一致意见后，签订的书面材料。协议书是契约文书的一种。是当事人双方（或多方）为了解决或预防纠纷，或确立某种法律关系，实现一定的共同利益、愿望，经过协商而达成一致后，签署的具有法律效力的记录性应用文";
    contentlb.numberOfLines = 0;
    contentlb.textColor = rgb_51;
    contentlb.font = MediumFont(12);
    contentlb.textAlignment = NSTextAlignmentCenter;
    contentlb.height = [ToolClass getLabelHeight:contentlb Font:MediumFont(12)];
    [_scroller addSubview:contentlb];
    
    checkUpdate = [[UIButton alloc]initWithFrame:CGRectMake(50, contentlb.bottom + 30, KScreenWidth - 100, 44)];
    checkUpdate.layer.cornerRadius = checkUpdate.height/2;
    checkUpdate.layer.borderWidth = 1;
    checkUpdate.layer.borderColor = rgb(255,116,2).CGColor;
    [checkUpdate setTitle:@"检查更新" forState:0];
    checkUpdate.titleLabel.font = MediumFont(15);
    [checkUpdate setTitleColor:rgb(255,116,2) forState:0];
    [checkUpdate addTarget:self action:@selector(checkUpdateEvent) forControlEvents:UIControlEventTouchUpInside];
    [_scroller addSubview:checkUpdate];
    
    clearBtn = [[UIButton alloc]initWithFrame:CGRectMake(50, checkUpdate.bottom + 15, KScreenWidth - 100, 44)];
    clearBtn.layer.cornerRadius = clearBtn.height/2;
    clearBtn.layer.borderWidth = 1;
    [clearBtn setTitle:@"清除缓存" forState:0];
    [clearBtn setTitleColor:rgb(255,116,2) forState:0];
    clearBtn.titleLabel.font = MediumFont(15);
    clearBtn.layer.borderColor = rgb(255,116,2).CGColor;
    [clearBtn addTarget:self action:@selector(clearButtonEvent) forControlEvents:UIControlEventTouchUpInside];
    [_scroller addSubview:clearBtn];
    _scroller.contentSize = CGSizeMake(KScreenWidth, clearBtn.bottom + 60);
    
    
    
}
#pragma mark- 检测更新
-(void)checkUpdateEvent{
    
}
-(void)clearButtonEvent{
    
}
#pragma mark- 计算缓存
-(void)getCacheData{
    //    [self showHUDWithString:@"正在计算缓存..."];
    __weak typeof(self) weakSelf = self;
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        [NSThread sleepForTimeInterval:1.0];
        unsigned long long size = [SDImageCache  sharedImageCache].getSize;
        if (weakSelf == nil) return;
        NSString *sizeText = nil;
        if (size >= pow(10, 9)) {
            sizeText = [NSString stringWithFormat:@"%.2fGB", size / pow(10, 9)];
        } else if (size >= pow(10, 6)) {
            sizeText = [NSString stringWithFormat:@"%.2fMB", size / pow(10, 6)];
        } else if (size >= pow(10, 3)) {
            sizeText = [NSString stringWithFormat:@"%.2fKB", size / pow(10, 3)];
        } else {
            sizeText = [NSString stringWithFormat:@"%lluB", size];
        }
    });
    
    
}
#pragma mark- 清除缓存
-(void)clearClick{
    [[SDImageCache sharedImageCache] clearMemory];
    
}

#pragma mark 下拉刷新数据请求
- (void)getSystemAnnouncement{
    NSDictionary *dic = @{
                          @"pagenum":@"1",
                          @"pagesize":@"10",
                          };
    
    [ZWJNetworkManager requestWithRequestData:dic WithUrl:@"" WithWithCompletionBlockWithSuccess:^(NSDictionary *dic) {
        [self.scroller.mj_header endRefreshing];
        if ([dic[Code] integerValue] == 200) {
            if (dic[Response] == nil) {

            }else{
                [self showWithTitle:dic[Msg]];
            }
        }
    } failure:^(id error) {
        [self.scroller.mj_header endRefreshing];
        [self.scroller.mj_footer endRefreshing];
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
